﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Collector
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new FormMain());
            //单个程序运行
            bool ret;
            System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out ret);

            if (ret)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                string ConfigFilePath = Application.StartupPath + "\\Setting.config";
                if (!FileConfig.ReadCommonConfig(ConfigFilePath))
                {
                    MessageBox.Show("read Common File Config Fail, please Check...path is..." + ConfigFilePath);
                    FileConfig.Max_Dut_Count = 4;
                }

                if (FileConfig.CommonParam.iSelectedTestmode == 2)
                {
                    Application.Run(new Certified.CertifiedForm());                    
                }
                else if (FileConfig.CommonParam.iSelectedTestmode == 3)
                {
                    Application.Run(new PulseFixture.FixtureForm());
                } 
                else if (FileConfig.CommonParam.iSelectedTestmode == 4)
                {
                    Application.Run(new Factory.FactoryForm());
                }
                else
                {
                    Application.Run(new FormMain());
                }
            }
            else
            {
                MessageBox.Show("Please do not open more than one program, there are already programs running!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
    }
}
